package com.sh3h.generator.web.controller;

import com.sh3h.generator.web.dtos.GenCodeDto;
import com.sh3h.generator.web.dtos.Result;
import com.sh3h.generator.web.service.GenTableService;
import com.sh3h.generator.web.service.IGenService;
import com.sh3h.generator.web.service.impl.GenDatasourceServiceImpl;
import com.sh3h.generator.web.service.impl.GenTableServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"/api/gen"})
public class GenerateController {
    @Autowired
    private GenTableServiceImpl fieldTypeService;
    @Autowired
    private GenDatasourceServiceImpl genDatasourceService;
    @Autowired
    private GenTableService genTableService;
    @Autowired
    private IGenService genService;

    @PostMapping("")
    public Result gen(@RequestBody GenCodeDto dto) {
        for (Long tableId : dto.getTableIds()) {
            genService.generatorCode(tableId, dto);
        }
        return Result.success("");
    }
}
